import Vue from "vue";
import VueRouter from "vue-router";
import homeRouter from "../routerModules/home/homeRouter";
import doctorRouter from "../routerModules/askDoctor/doctorRouter";
import newsRouter from "../routerModules/news/newsRouter";
import mineRouter from "../routerModules/mine/mineRouter";
import LoginRouter from "../routerModules/login/LoginRouter";
import ServiceRouter from "../routerModules/login/LoginRouter";
import PhoneRouter from "../routerModules/login/LoginRouter";
import RegRouter from "../routerModules/login/LoginRouter";
import {isToken} from '../utils/token'
Vue.use(VueRouter);

const routes = [
  ...homeRouter,
  ...doctorRouter,
  ...newsRouter,
  ...mineRouter,
  ...LoginRouter,
  ...ServiceRouter,
  ...PhoneRouter,
  ...RegRouter,
  // {
  //   path: "/Zhengzhou",
  //   name: "Zhengzhou",
  //   component: () => import("../views/zhengzhou/Zhengzhou.vue"),
  // },

  // //郑州里面的页面跳转 开始
  // {
  //   path: "/Zhengzhou/maixian",
  //   name: "maixian",
  //   component: () => import("../views/zhengzhou/zhengzhous/maixian.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // //郑州里面的页面跳转 结束

  // {
  //   path: "/New",
  //   name: "New",
  //   component: () => import("../views/News/New.vue"),
  // },
  // {
  //   path: "/Mine",
  //   name: "Mine",
  //   component: () => import("../views/Mine/Mine.vue"),
  // },
];

const router = new VueRouter({
  routes,
});
router.beforeEach((to, from, next) => {
  if (to.meta.needLogin) {
    if (isToken()) {
      next();
    } else {
      next("/phone");
    }
  } else {
    next();
  }
});

export default router;
